﻿Public Class History_Window

    Sub New()
        If MainForm.conLanguageDe.Checked Then
            System.Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("de")
        Else
            System.Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en")
        End If
        Me.KeyPreview = True
        InitializeComponent()
    End Sub

    Private Sub History_Window_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Location = New Point(MainForm.Location.X + 30, MainForm.Location.Y + 30)
        For Each item In MainForm.history_list
            lstHistory.Items.Add(item)
        Next
        lstHistory.SelectedIndex = lstHistory.Items.Count - 1
    End Sub

    Private Sub key_Check(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.Escape Then
            Me.Close()
        End If
    End Sub

    Private Sub butClear_Click(sender As Object, e As EventArgs) Handles butClear.Click
        lstHistory.Items.Clear()
        MainForm.history_list.Clear()
        lstHistory.Focus()
    End Sub

    Private Sub butDelete_Click(sender As Object, e As EventArgs) Handles butDelete.Click, conDelete.Click
        If lstHistory.SelectedIndex <> -1 Then
            MainForm.history_list.RemoveAt(lstHistory.SelectedIndex)
            lstHistory.Items.Remove(lstHistory.SelectedItem)
        End If
        lstHistory.Focus()
    End Sub

    Private Sub butCopy_Click(sender As Object, e As EventArgs) Handles butCopy.Click, conCopy.Click
        If lstHistory.SelectedIndex <> -1 Then Clipboard.SetText(lstHistory.SelectedItem)
        lstHistory.Focus()
    End Sub

    Private Sub conToABC_Click(sender As Object, e As EventArgs) Handles conToABC.Click
        If lstHistory.Items.Count > 0 Then MainForm.conToABC_Click(sender, e)
    End Sub
End Class